package hero;

import java.util.ArrayList;

/**
 * Created by Роман on 04.05.14.
 */
public class protagonist
{
    private int hp;//10 жизней
    private int speed;//совершение действия, выстрел, хотьба
    //private ArrayList<String> inventory;//нож, зелье лечения(2)
    private boolean [] potion;
    private boolean treasure;// клад
    private String key;// ключ(1)
    private int coordX;
    private int coordY;

    public protagonist(int valX, int valY)
    {
        coordX = valX;
        coordY = valY;
        hp = 10;
        speed = 1;
        potion = new boolean[2];
        potion[0] = true;
        potion[1] = true;
//        inventory = new ArrayList<String>();
//        inventory.add(0, "knife");
////        inventory.add(1, "bow");
////        inventory.add(2, "arrow");
////        inventory.add(3, "arrow");
////        inventory.add(4, "arrow");
////        inventory.add(5, "arrow");
//        inventory.add(1, "potion");
//        inventory.add(2, "potion");
        treasure = false;
        key = "none";

        return;
    }

    public void setCoords(int x, int y)
    {
        coordX = x;
        coordY = y;

        return;
    }

    public int getCoordX()
    {
        return coordX;
    }

    public int getCoordY()
    {
        return coordY;
    }

    public void setHp(int type)
    {
        switch (type)
        {
            case 1://hit
            {
                if(hp !=0)
                    hp--;
                break;
            }
            case 2://heal
            {
                if(hp != 10)
                    hp += 5;
                if(hp > 10)
                    hp = 10;
                break;
            }
        }
        return;
    }

    public int getHp()
    {
        return this.hp;
    }

    public void setSpeed(int type)
    {
        switch (type)
        {
            case 1://increase
            {
                speed++;
                break;
            }
            case 2://decrease
            {
                speed--;
                break;
            }
        }
        return;
    }

    public int getSpeed()
    {
        return this.speed;
    }

//    public void setInventory(String value)
//    {
//        this.inventory.add(value);
//        return;
//    }

//    public boolean getInventory(String value)
//    {
//        if(this.inventory.contains(value))
//            return true;
//        else
//            return false;
//    }

//    public void useInventory(String item)
//    {
//        if (getInventory(item))
//        {
//            this.inventory.remove(this.inventory.indexOf(item));
//        }
//        return;
//    }
    public boolean usePotion()
    {
        if((potion[0])||(potion[1]))
        {
            if(potion[1])
            {
                potion[1] = false;
                return true;
            }
            if(potion[0])
            {
                potion[0] = false;
                return true;
            }
        }
        return false;
    }
    public int countPotion()
    {
        if((potion[0])&&(potion[1]))
        {
            return 2;
        }
        if((potion[0])||(potion[1]))
        {
            if(potion[1])
            {
                return 1;
            }
            if(potion[0])
            {
                return 1;
            }
        }
        return 0;
    }

    public void setKey(String value)
    {
        this.key = value;
        return;
    }

    public void setTreasure(boolean value)
    {
        this.treasure = value;
        return;
    }

    public String getKey()
    {
        return this.key;
    }

    public boolean getTreasure()
    {
        return this.treasure;
    }
}